package main

import (
	"context"
	"fmt"
	"gitee.com/xiao_hange/go-admin-log/log/ioc"
	"os"
	"os/signal"
	"syscall"
	"time"
)

func main() {
	//serverName := os.Args[1]
	serverName := "log_1"
	ac := ioc.InitOther(serverName)
	closeFunc := ioc.InitOTEL(ac.Jaeger)
	app := InitApp(ac.Server, ac.Jaeger, ac.Es)
	go func() {
		err := app.server.Serve()
		if err != nil {
			panic("服务启动失败" + err.Error())
		}
	}()
	quit := make(chan os.Signal)
	signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
	<-quit
	ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
	defer cancel()
	closeFunc(ctx)
	if err := app.server.Close(); err != nil {
		fmt.Println("服务启动失败" + err.Error())
	}
}
